package gui.customizepanel;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class JPicturePanel extends JPanel {
	private static final long serialVersionUID = 0xA1L;

	private String imagePath;

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public String getImagePath() {
		return this.imagePath;
	}

	public JPicturePanel(String imagePath) {
		this.imagePath = imagePath;
		this.setOpaque(false);
	}

	public JPicturePanel() {
		this.imagePath = "src/icons/logo.png";
		this.setOpaque(false);
	}

	@Override
	protected void paintComponent(Graphics g) {
		ImageIcon imageIcon = new ImageIcon(this.imagePath);
		int width = imageIcon.getIconWidth();
		int height = imageIcon.getIconHeight();

		Image image = imageIcon.getImage();
		Dimension d = getSize();

		g.drawImage(image, (d.width - width) / 2, (d.height - width) / 2,
				width, height, this);
		super.paintComponent(g);
	}
}
